package com.design_pattern._01_create._05_abstract_factory;

public abstract class AbstractFactory {
    abstract Food createFood();
    abstract Vehicle createVehicle();

    public static void main(String[] args) {
        AbstractFactory factory = new ModernFactory();
        Food food = factory.createFood();
        Vehicle vehicle = factory.createVehicle();
        System.out.println("张三，在现代，乘坐" + vehicle.getClass().getSimpleName()+"吃着"+food.getClass().getSimpleName());

    }

}

/**
 * 现代工厂
 */
class ModernFactory extends AbstractFactory{

    @Override
    Food createFood() {
        return new Apple();
    }

    @Override
    Vehicle createVehicle() {
        return new Car();
    }
}

/**
 * 魔法工厂
 */
class MagicFactory extends AbstractFactory{

    @Override
    Food createFood() {
        return new Bushroom();
    }

    @Override
    Vehicle createVehicle() {
        return new Broom();
    }
}
